
/*
 * @Date: 2024-11-22 10:06:39
 * @Author: LiSong
 * @LastEditors: g05047
 * @LastEditTime: 2025-02-26 16:37:49
 * @Description: 数据列表
 */
import schema from './schema.js'
import * as baseOption from '@hp/config/option/echarts/echarts-base.js'
import * as legendOption from '@hp/config/option/echarts/echarts-legend.js'
import * as tooltipOption from '@hp/config/option/echarts/echarts-tooltip.js'
import { useDbSource } from '@hp/hooks/useDbSource.js'

const { loadDataCols } = useDbSource()

export default {
  // 组件
  component: () => import("./ChartPie.vue"),
  // 类型
  type: 'chartpie',
  // 名称
  name: '饼状图',
  // 图标或图片
  icon: 'pi/chart-pie.png',
  schema,
  // 大小定位
  layout: {
    i: '',
    x: '',
    y: '',
    w: 60,
    h: 35,
    minW: 24,
    minH: 12,
    maxW: 120,
    // maxH: 35,
    static: false,
  },
  // 配置
  config: [
    {
      config: {
        label: '基础配置'
      },
      children: [
      ]
    },
    {
      config: {
        label: '数据配置'
      },
      children: [
        {
          type: 'input-cards',
          field: 'dataList',
          label: '数据集',
          noForm: true,
          compProps: {
            mustHas: true,
            showAdd: false,
          },
          children: [
            {
              type: "input-dbsource",
              label: "数据源",
              field: "dataList.dataSource",
              compProps: {
              }
            },
            {
              type: "select",
              label: "维度",
              field: "dataList.labelName",
              compProps: {
                clearable: true,
                // defaultValue: 'value',
                getUpConfig({ row, schema, config }) {
                  return {
                    options: loadDataCols(row)
                  }
                }
              }
            },
            {
              type: "select",
              label: "指标",
              field: "dataList.labelKey",
              compProps: {
                clearable: true,
                // defaultValue: 'value',
                getUpConfig({ row, schema, config }) {
                  return {
                    options: loadDataCols(row)
                  }
                }
              }
            },
         
          ]
        },
      ]
    },
    {
      config: {
        label: '饼图设置'
      },
      children: [
        {
          type: "series-pie",
          label: "颜色/路径",
          field: "color",
          compProps: {
            defaultValue: [],
            configData: {
              name: '',
              value: '',
              color: '',
              path: '',
              params: '',
            }
          }
        },
        {
          type: 'select',
          field: 'echarts.series.pie.selectedMode',
          label: '选中类型',
          compProps: {
            options: baseOption.PieSelectTypeOptions,
            clearable: true,
          }
        },
        {
          type: 'select',
          field: 'echarts.series.pie.clockwise',
          label: '生成方向',
          compProps: {
            options: baseOption.PieDirectionOptions,
            clearable: true,
          }
        },
        {
          type: 'number',
          field: 'echarts.series.pie.selectedOffset',
          label: '偏移距离',
          compProps: {
            defaultValue: 0,
          }
        },
        {
          type: 'slider',
          field: 'echarts.series.pie.startAngle',
          label: '开始角度',
          compProps: {
            defaultValue: 0,
            min: 0,
            max: 360,
          }
        },
        {
          type: 'slider',
          field: 'echarts.series.pie.endAngle',
          label: '结束角度',
          compProps: {
            defaultValue: 360,
            min: 0,
            max: 360,
          }
        },
        {
          type: 'slider',
          field: 'echarts.series.pie.padAngle',
          label: '扇区间隙',
          compProps: {
            defaultValue: 0,
            min: 0,
            max: 100,
          }
        },
        {
          type: 'slider',
          field: 'echarts.series.pie.radiusN',
          label: '圆心大小',
          compProps: {
            defaultValue: 40
          }
        },
        {
          type: 'slider',
          field: 'echarts.series.pie.radiusW',
          label: '外圆大小',
          compProps: {
            defaultValue: 60,
            min: 0,
            max: 300
          },
        },
        {
          type: 'slider',
          field: 'echarts.series.pie.centerH',
          label: '水平位置',
          compProps: {
            defaultValue: 50
          }
        },
        {
          type: 'slider',
          field: 'echarts.series.pie.centerV',
          label: '垂直位置',
          compProps: {
            defaultValue: 50
          }
        },
        {
          type: 'slider',
          field: 'echarts.series.itemStyle.borderRadius',
          label: '圆角大小',
          compProps: {
            defaultValue: 0
          }
        },
        {
          type: 'select',
          field: 'echarts.series.roseType',
          label: '南丁格尔图方向',
          compProps: {
            options: baseOption.PieRoseTypeOptions,
            clearable: true,
          }
        },
      ]
    },
    {
      config: {
        label: '文本设置'
      },
      children: [
        {
          type: 'switch',
          field: 'echarts.series.label.show',
          label: '是否显示',
          compProps: {
          }
        },
        {
          type: 'input-color',
          field: 'echarts.series.label.color',
          label: '文本颜色',
          compProps: {
            getUpConfig({ schema }) {
              return {
                display: schema.echarts.series.label.show
              }
            }
          }
        },
        {
          type: 'input-color',
          field: 'echarts.series.label.backgroundColor',
          label: '文本底色',
          compProps: {
            getUpConfig({ schema }) {
              return {
                display: schema.echarts.series.label.show
              }
            }
          }
        },
        {
          type: 'select',
          field: 'echarts.series.label.position',
          label: '文本位置',
          compProps: {
            defaultValue: 'outside', // 默认值
            options: baseOption.PieLabelPositionOptions,
            getUpConfig({ schema }) {
              return {
                display: schema.echarts.series.label.show
              }
            }
          }
        },
        {
          type: 'select',
          field: 'echarts.series.label.fontWeight',
          label: '文本粗细',
          compProps: {
            options: baseOption.FontWeightOptions,
            getUpConfig({ schema }) {
              return {
                display: schema.echarts.series.label.show
              }
            }
          }
        },
        {
          type: 'number',
          field: 'echarts.series.label.fontSize',
          label: '字体大小',
          compProps: {
            defaultValue: 14,
            getUpConfig({ schema }) {
              return {
                display: schema.echarts.series.label.show
              }
            }
          }
        },
        {
          type: 'input',
          field: 'echarts.series.label.formatter',
          label: '文本内容',
          compProps: {
            getUpConfig({ schema }) {
              return {
                display: schema.echarts.series.label.show
              }
            }
          }
        },
      ],
    },
    {
      config: {
        label: '图例设置'
      },
      children: [
        {
          type: 'switch',
          field: 'echarts.legend.show',
          label: '是否显示',
          compProps: {
            defaultValue: true,
          }
        },
        {
          type: 'select',
          field: 'echarts.legend.orient',
          label: '布局朝向',
          compProps: {
            options: legendOption.LegendOrientOptions,
          }
        },
        {
          type: 'select',
          field: 'echarts.legend.align',
          label: '所在位置',
          compProps: {
            options: legendOption.LegendAlignOptions
          }
        },
      ]
    },
    {
      config: {
        label: '提示框设置'
      },
      children: [
        {
          type: 'select',
          field: 'echarts.tooltip.axisPointer.type',
          label: '类型',
          compProps: {
            options: tooltipOption.AxisPointerTypeOptions
          }
        },
        {
          type: 'select',
          field: 'echarts.tooltip.trigger',
          label: '触发类型',
          compProps: {
            options: tooltipOption.TooltipTriggerOptions
          }
        },
      ]
    },
    {
      config: {
        label: '事件属性'
      },
      children: [
        {
          type: 'event-onclick',
          field: 'onClick',
          label: 'onClick',
          compProps: {
          }
        }
      ]
    },
  ]
}

